package com.example.lay.intent;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * Created by Lay on 2014/12/7.
 */
public class DataAndTypeAcvitity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activi_data_and_type);
        //覆盖Type
        ((Button) findViewById(R.id.btnOtype)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setType("abc/xyz");
                intent.setData(Uri.parse("cl://api.lalio.xyz:877/core"));
                Toast.makeText(DataAndTypeAcvitity.this, intent.toString(), Toast.LENGTH_LONG).show();
            }
        });
        //覆盖Data
        ((Button) findViewById(R.id.btnOdata)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setData(Uri.parse("cl://api.lalio.xyz:877/core"));
                intent.setType("abc/xyz");
                Toast.makeText(DataAndTypeAcvitity.this, intent.toString(), Toast.LENGTH_LONG).show();
            }
        });
        //TypeData全部设置
        ((Button) findViewById(R.id.btnDataAndType)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setDataAndType(Uri.parse("cl://api.lalio.xyz:877/core"), "abc/xyz");
                Toast.makeText(DataAndTypeAcvitity.this, intent.toString(), Toast.LENGTH_LONG).show();
            }
        });
    }
}
